package com.atguigu.cloud.handler;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component;

/**
 * @author bairimengchang
 * @version 1.0
 * @project cloud2024
 * @description
 * @date 2024/11/4
 */
@Component
public class MyRequestOriginParser implements RequestOriginParser
{
    // 获取请求头中的一个参数，作为sentinel的授权规则验证参数
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        return httpServletRequest.getParameter("serverName");
    }
}